﻿
@{
    ViewBag.Title = "管理员列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="wap-container">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px">
        首页
        <span class="c-gray en">/</span>
        权限管理
        <span class="c-gray en">/</span>
        管理员列表
        <a class="btn btn-success radius f-r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <article class="Hui-admin-content clearfix">
        <div class="panel mt-20">
            <div class="panel-body">
                <div class="layui-btn-group table-btn">
                    <button class="layui-btn" onclick="add_data('添加管理员', '/PermManage/AdminUser/Add', false, 800, 450)"><i class="layui-icon">&#xe654;</i>添加管理员</button>
                    <button class="layui-btn layui-btn-danger" id="batchDelete"><i class="layui-icon">&#xe640;</i>批量删除</button>
                </div>
                <div class="mt-20 clearfix">
                    <table class="layui-table" id="adminform" lay-filter="adminform"></table>
                    <script type="text/html" id="bar">
                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </article>
</div>
<script type="text/html" id="isLockTpl">
    {{# if(d.isLock==0){ }}
    <span>正常</span>
    {{# }else{ }}
    <span>锁定</span>
    {{# } }}
</script>
@section FooterScript{
    <script type="text/javascript">
        layui.use(['table', 'layer'], function () {
            var table = layui.table,
                layer = layui.layer;

            var tableIns = table.render({
                elem: '#adminform',
                url: '/PermManage/AdminUser/ListData',
                request: {
                    page: 1,
                    limit: 10
                },
                page: true,
                cols: [[
                    { type: 'checkbox', fixed: 'left' },
                    { field: 'id', width: 80, hide: true },
                    { field: 'userName', title: '登录名' },
                    { field: 'telPhone', title: '手机号', width: 150, align: 'center' },
                    { field: 'email', title: '邮箱', width: 240, align: 'center' },
                    { field: 'roleName', title: '所属角色', width: 150, align: 'center' },
                    { field: 'addTime', title: '加入时间', width: 180, align: 'center' },
                    { field: 'isLock', title: '状态', width: 120, align: 'center', templet:'#isLockTpl' },
                    { field: 'right', title: '操作', width: 150, align: 'center', toolbar: '#bar' }
                ]],
                response: {
                    statusCode: 200,
                    countName: 'totalCount'
                }
            })

            //表格工具栏
            table.on('tool(adminform)', function (obj) {
                var data = obj.data;
                var layEvent = obj.event;

                if (layEvent === 'edit') {
                    edit_data('编辑', '/PermManage/AdminUser/Edit', data.id, false, 800, 450);
                } else if (layEvent === 'del') {
                    layer.confirm('确定要删除【<span class="c-red">' + data.title + '</span>】管理员吗？', function (index) {
                        deleteData('/PermManage/AdminUser/Delete', data.id, index, obj);
                    })
                }
            })

            //批量删除
            $('#batchDelete').on('click', function () {
                var checkStatus = table.checkStatus('adminform');
                batchDelete('/PermManage/AdminUser/BatchDelete', checkStatus, tableIns)
            })
        })
    </script>
}